package com.mowwang.file;

import java.io.FileWriter;
import java.io.IOException;

public class Me {
    public static void main(String[] args) {
        FileWriter fileWriter=null;
        try {
            fileWriter=new FileWriter("b.txt");
            char[] chars={'a','b','c','d'};
            //直接写入字符数组
            fileWriter.write(chars);
            fileWriter.write("efgh",2,2);
            fileWriter.write(chars,3,1);
            //写入完毕，冲刷缓冲区
            fileWriter.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fileWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
